import ReactDOM from "react-dom";
import React, { Component } from "react";
import PropTypes from 'prop-types'


const Demo = (props) => {
  return <div>Demo组件</div>
}
// props校验
Demo.propTypes = {
  // 函数
  optionalFunc: PropTypes.func,
  // 必填 + 函数
  requiredFunc: PropTypes.func.isRequired,
  // 特定结构的对象 {color:字符串,fontSize:数字}
  optionalObjectWithShape: PropTypes.shape({
    color: PropTypes.string,
    fontSize: PropTypes.number
  })
}


class App extends Component {
  render() {
    return (
      <div className="app">
        <Demo requiredFunc={()=>{}} optionalObjectWithShape={{
          color: 'red',
          fontSize: 10
        }} />
      </div>
    );
  }
}

ReactDOM.render(<App />, document.getElementById("root"));
